<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function ajax(url) {
            return new Promise(function(resolve,reject) {
                var xhr = new XMLHttpRequest();
                xhr.open("GET",url,true)
                xhr.send();
                xhr.onreadystatechange = function() {
                    if(xhr.readyState == 4) {
                        if(xhr.status == 200) {
                            resolve( xhr.responseText )
                        }else{
                            reject("出错了---")
                        }
                    }
                }
            })
        }
        // ajax("./data/01.json").then((d)=>{
        //     console.log(d);
        //     return ajax("./data/02.json")
        // })
        // .then((d)=>{
        //     console.log(d);
        // })
        // .catch((d)=>{
        //     console.log(d);
        // })

        async function getList() {
            try {
                let a = await ajax("./data/01.json");
                let b = await ajax("./data/02.json");
                console.log(a,b);
            } catch {
                console.log("try中的出错了,执行catch这里的代码");
            }
        }

        getList();
    </script>
</body>
</html>